Skip to content

perf(server): branch lists no longer wait on folder checks one at a time - #1020

Merged
badcuban merged 1 commit into
mainfrom
perf/list-refs
Nov 20, 2026
Merged

badcuban merged 1 commit into
mainfrom
perf/list-refs

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

Listing branches (vcs.listRefs, used by the branch picker and by every new worktree thread) took 1.5s typical and up to 16s on a repository with ~90 worktrees. The server traces put most of it in parseWorktreeList, up to 6.4s: it checked each git worktree list entry's folder one stat at a time, and on a busy server every stat waits its turn. VcsProjectConfig.findConfigPath did the same walking up parent folders (0.6 to 1.2s per call).

Both now run their checks side by side:

  • parseWorktreeList reuses parseWorktreeRegistrations and checks up to 64 folders at once. Results are unchanged: missing folders are skipped, git's order is kept, and so are branch and lock reason. The shared parser now handles CRLF output too.
  • findConfigPath checks every candidate at once and answers as soon as the nearest existing vcs.json is known, so a stalled check further up (an unreachable network mount) doesn't hold it.

Measured on the real 90-worktree repository with a simulated busy event loop: the folder checks went from 2.7s to 30ms. When the server is idle, both ways take a few milliseconds.

Tests: two new cases in VcsProjectConfig.test.ts: the nearest config wins, and a check further up that never answers doesn't block the lookup. The second one hangs on a version that waits for every check. Existing worktree-listing tests cover skipped folders and lock reasons. 305 git-related server tests pass, along with fmt, lint and typecheck. Reviewed by GPT-6.2-Astra; both of its findings (stalled check, CRLF) are fixed here.

Not in this PR: a listing is read twice when a background remote fetch finishes during it, and filesystem calls on a busy server wait about 70ms each, which suggests broader event-loop load.

vcs.listRefs took 1.5s typical and up to 16s on a repository with ~90
worktrees. Traces put most of it in parseWorktreeList (up to 6.4s): it
stat'ed each `git worktree list` entry's folder one after another, and on
a busy server each stat waits its turn. VcsProjectConfig.findConfigPath did
the same walking up parent folders (0.6-1.2s).

Both now run their checks side by side. parseWorktreeList reuses
parseWorktreeRegistrations (now tolerant of CRLF output) and stats up to 64
folders at once; results and order are unchanged. findConfigPath checks
every candidate at once and answers as soon as the nearest existing one is
known, so a stalled check further up (an unreachable mount) doesn't hold it.

On the real 90-worktree repository with a simulated busy event loop, the
folder checks went from 2.7s to 30ms.
@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Nov 20, 2026 6:17pm UTC

Request Review

@badcuban
badcuban added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit a5cd14f Nov 20, 2026
23 checks passed
@badcuban
badcuban deleted the perf/list-refs branch November 20, 2026 18:28

This branch was previously deployed

1 inactive deployment
Preview — 04ec615f Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant